// Contains general properties of atoms and related utility functions.

#ifndef ATOM_H
#define ATOM_H

// Potassium's Van Der Waals radius.
// Max for both covalent and Van Der Waals.
#define MAX_ATOMIC_RADIUS 2.75

/*struct Material {
	Color ambient, diffuse, specular;
	float n;
};
//*/

// Gross overestimate
#define MAX_ALPHA_CARBON_DISTANCE (0.68*4 + 0.68*2)

// Gross overestimate
#define MAX_DNA_DISTANCE (0.68*6 + 0.68*4 + 1.05*2)

// More info than I need, but simpler to stick it all in a table than
// add something I currently dont need later.
struct AtomicInfo {
	const char *name;
	const char *symbol;
	char group;
	char block;
	unsigned short number;
	float weight;
	float covalentRadius;
	float vanDerWaalsRadius;
	int colorIndex;
};

extern AtomicInfo *atomicInfoTable[26*27];
void InitAtomicInfo();

AtomicInfo *GetAtomicInfo(const char *symbol);
unsigned int AtomicSymbolToInt(const char *symbol);

inline AtomicInfo *GetAtomicInfoById(int id) {
	return atomicInfoTable[id];
}

inline double GetAtomicCovalentRadius(char *id) {
	AtomicInfo *info = GetAtomicInfo(id);
	if (info) return info->covalentRadius;
	// ???
	return 0;
}


inline double GetAtomicVanDerWaalsRadius(char *id) {
	AtomicInfo *info = GetAtomicInfo(id);
	if (info) return info->covalentRadius;
	// ???
	return 0;
}


inline double GetAtomicAverageRadius(int atomicId) {
	AtomicInfo *info = atomicInfoTable[atomicId];
	if (info) return (1.2*info->covalentRadius);
	//if (info) return (2*info->covalentRadius + info->vanDerWaalsRadius)/3;
	// ???
	return 0;
}

inline double GetAtomicAverageRadius(char *id) {
	unsigned int atomicId = AtomicSymbolToInt(id);
	return GetAtomicAverageRadius(atomicId);
}

int SymbolEquals(char *symbol1, char *symbol2);

Color GetAtomicColor(char *id);
Color GetAtomicColor(int index);
Color GetAtomicColorByAtomIndex(int index);

#endif
